<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>公众号管理</title>
		[#include "/html/include/easyuicss.html" /]
		[#include "/html/include/easyuijs.html" /]
		<script type="text/javascript" src="${app }/static/js/common.utils.js"></script>
	</head>
	<body class="easyui-layout" data-options="fit:true" style="overflow-y: hidden">
	<table id="dgtable" class="easyui-datagrid" style="width:100%;height:100%;">
		<thead>
		<tr>
			<th data-options="field:'account_name',width:100">公众号名称</th>
			<th data-options="field:'account_email',width:120">邮箱</th>
			<th data-options="field:'weix_number',width:100">微信号</th>
			<th data-options="field:'weix_id',width:100">openid</th>
			<th data-options="field:'weix_type_name',width:60">公众号类型</th>
			<th data-options="field:'token',width:100,formatter:getText">Token</th>
			<th data-options="field:'aeskey',width:100,formatter:getText">aeskey</th>
			<th data-options="field:'operating',width:160,formatter:getBtn">操作</th>
		</tr>
		</thead>
	</table>
	<div id="tb">
		<span>公众号名称:</span>
		<input  class="easyui-textbox" id="accountName" name="accountName" />
		<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="showList();">查询</a>
		<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="parent.easyui.createWindow('公众号管理', '${app}/weixin/account/edit.do?method=create', '550px', '500px', window.name);">新增</a>
		<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="resetAccessToken();">重置Token</a>
	</div>
	</body>
    <script type="text/javascript">
		$(document).ready(function(){
			$('#dgtable').datagrid({
				url: '${app}/weixin/account/list.do',
				method: 'post',
				queryParams: {accountName: $('#accountName').val()},
				singleSelect: true,
                fitColumns: true,
				toolbar: '#tb',
				onLoadSuccess: onLoadSuccess,
				pagination: true,
				pageSize: 20,
				pageList: [10,20,30]
			});
		});
		function getBtn(value, row, index) {
			return '<a href="javascript:;" class="easyui-linkbutton" onclick="parent.easyui.createWindow(\'公众号管理\', \'${app}/weixin/account/edit.do?method=edit&accountId='+row.account_id+'\', \'550px\', \'500px\', window.name);">编辑</a>&nbsp;'+
					'<a href="javascript:;" class="easyui-linkbutton" onclick="openAcctMgr(\''+row.account_id+'\');">功能管理</a>&nbsp;'+
					'<a href="javascript:;" class="easyui-linkbutton" onclick="weixinHelp(\''+row.account_id+'\');">接口配置</a>&nbsp;'+
					'<a href="javascript:;" class="easyui-linkbutton" onclick="deleteInfo(\''+row.account_id+'\');">删除</a>&nbsp;';
		}
        function getText(value, row, index) {
            return "<span title='"+value+"'>"+value+"</span>";
        }
		function onLoadSuccess(data){
			$('.easyui-linkbutton').linkbutton();
		}
		function showList(){
			$('#dgtable').datagrid('load', {
				accountName: $('#accountName').val()
			});
		}
		function deleteInfo(accountId){
			parent.easyui.confirm('系统提醒', '您确定要删除该条记录吗？', function(r){
				if (r){
					parent.layer.load(2);
					common.ajax('${app}/weixin/account/delete.do', 'accountId='+accountId,
						'POST', 'json', false,
						function(result){
							parent.layer.closeAll('loading');
							parent.easyui.msgShow('系统提醒', result.msg, 3000, 250, 100);
							if (result.result == 1) {
								showList();
							}
						}
					);
				}
			});
		}
		function openAcctMgr(accountId){
			window.open('${app}/weixin/account/index.do?accountId='+accountId);
		}
		function resetAccessToken(){
			common.ajax('${app}/weixin/account/resetAccessToken.do', '',
					'POST', 'json', true,
					function(result){
						parent.layer.closeAll('loading');
						parent.easyui.msgShow('系统提醒', result.msg, 3000, 250, 100);
					}
			);
		}
		function weixinHelp(accountId){
			parent.easyui.createWindow('微信接口配置',
					'${app}/weixin/account/help.do?accountId='+accountId,
					'900px', '600px', window.name);
		}
    </script>
</html>